package com.yidu.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.yidu.bean.TbRole;
import com.yidu.dao.TbRoleMapper;
import com.yidu.message.Page;
import com.yidu.message.Pages;
import com.yidu.service.TbRoleService;

/**
 * 类的描述--
 * @author 楠竹
 * @date 2018年7月24日
 * @version 1.0
 */
@Service
public class TbRoleServiceImpl implements TbRoleService {


	//打印控制台
	Logger logger = Logger.getLogger(TbRoleServiceImpl.class);
	
	@Resource
	private TbRoleMapper roleDao;
	/* (non-Javadoc)
	 * @see com.yidu.service.TbRoleService#delete(java.lang.String)
	 */
	@Override
	public int delete(String roleId) {
		logger.info("删除...");
		int num = roleDao.deleteByPrimaryKey(roleId);
		return num;
	}

	/* (non-Javadoc)
	 * @see com.yidu.service.TbRoleService#save(com.yidu.bean.TbRole)
	 */
	@Override
	public int save(TbRole role) {
		logger.info("增加...");
		int num = roleDao.insertSelective(role);
		return num;
	}

	/* (non-Javadoc)
	 * @see com.yidu.service.TbRoleService#update(com.yidu.bean.TbRole)
	 */
	@Override
	public int update(TbRole role) {
		logger.info("修改...");
		int num = roleDao.updateByPrimaryKey(role);
		return num;
	}

	/* (non-Javadoc)
	 * @see com.yidu.service.TbRoleService#findVague(com.yidu.message.Page, com.yidu.bean.TbRole)
	 */
	@Override
	public List<TbRole> findVague(Pages pages, TbRole role) {
		logger.info("进入模糊查询...");
		List<TbRole> list = roleDao.findVague(role, pages);
		return list;
	}

	/* (non-Javadoc)
	 * @see com.yidu.service.TbRoleService#findAll()
	 */
	@Override
	public List<TbRole> findAll() {
		logger.info("查询所有...");
		List<TbRole> list = roleDao.findAll();
		return list;
	}

	@Override
	public TbRole findById(String roleId) {
		logger.info("根据id查询所有...");
		TbRole role = roleDao.selectByPrimaryKey(roleId);
		return role;
	}

	@Override
	public int findBycount(TbRole role) {
		logger.info("查询结果集...");
		int num  = roleDao.findByCount(role);
		return num;
	}

	@Override
	public int isvaUp(TbRole role) { 
		logger.info("是否有效...");
		int num = roleDao.update(role);
		return num;
	}

}
